package com.service.admin.member.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.service.admin.member.controller.req.MemberJAPageReq;
import com.service.core.rest.response.CommonPageRep;
import com.service.dao.po.MemberJAHRPo;
import com.service.dao.po.MemberJAPo;
import com.service.dao.query.JARecordPara;
import com.service.dao.mapper.JournalAccountMapper;
import com.service.dao.model.JournalAccount;
import com.service.admin.member.service.MemberJAService;
import com.service.utility.modelmapper.ModelMapperUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年10月07日</dd>
 * </dl>
 *
 * @author
 */
@Slf4j
@Service
@Transactional(readOnly = true, rollbackFor = Exception.class)
public class MemberJAServiceImpl extends ServiceImpl<JournalAccountMapper,JournalAccount > implements MemberJAService {

    @Override
    public CommonPageRep<MemberJAPo> pageMemberJA(MemberJAPageReq pageReq) {
        Page<MemberJAPo> page = PageHelper.startPage(pageReq.getPageNo(), pageReq.getPageSize());
        JARecordPara recordPara = ModelMapperUtil.getStrictModelMapper().map(pageReq, JARecordPara.class);
        recordPara.setCoinType(pageReq.getCoin().getCode());
        baseMapper.listMemberJA4Admin(recordPara);
        return CommonPageRep.buildResultRep(page);
    }


    @Override
    public CommonPageRep<MemberJAHRPo> pageMemberJAHR(MemberJAPageReq pageReq) {
        Page<MemberJAHRPo> page = PageHelper.startPage(pageReq.getPageNo(), pageReq.getPageSize());
        JARecordPara recordPara = ModelMapperUtil.getStrictModelMapper().map(pageReq, JARecordPara.class);
        recordPara.setCoinType(pageReq.getCoin().getCode());
        baseMapper.listJAHR4Admin(recordPara);
        return CommonPageRep.buildResultRep(page);
    }

    @Override
    public BigDecimal totalStatementByParam(String someDay, List<Integer> typeList) {
        return baseMapper.totalStatementByParam(someDay, typeList);
    }
}
